package cn.snailhd.api.test.api.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.snailhd.core.base.dao.MyBatisDao;
import cn.snailhd.core.base.domain.BaseResultDTO;
import cn.snailhd.utils.string.StringUtils;



@Controller
@RequestMapping(value="/api")
public class ApiController {

	@Autowired
	MyBatisDao dao;
	
	@RequestMapping(value="/list")
	@ResponseBody
	public String main(Map map){
		Object versionNo = map.get("version_no");
		if(versionNo==null || StringUtils.isBlank(versionNo+"")){
			 String version_no = dao.selectOne("apiMapper.queryRecentVersionNo",map.get("projectid"));
			 map.put("version_no", version_no);
		}
		BaseResultDTO re = new BaseResultDTO();
		List<Map> list=  dao.selectList("apiMapper.querylist", map);
		re.put("list", list);
		return re.setSuccess().toJSON();
	}
	
}
